<?php
include_once 'top/TopClient.php';
include_once 'top/RequestCheckUtil.php';
include_once 'TopSdk.php';
include_once 'top/request/ShopGetRequest.php';

class Txy_Util_TaobaoShop {
	private $c;
	private $db_ship;
	function __construct(){
		$this->c = new TopClient;
		$this->c->appkey = '12532098';
		$this->c->secretKey = 'c22aee3f68fe4acc9015a1e9dba1cd16';
		$this->db_ship=new Application_Model_DbTable_Shop();
	}
	
	public function addNewShop($nick_name){
		$req = new ShopGetRequest;
		$req->setFields("sid,cid,title,nick,desc,bulletin,pic_path,shop_score");
		$req->setNick($nick_name);
		$resp = $this->c->execute($req);
		if(isset($resp->shop)){
			$shop=$resp->shop;
			$data=Array();
			$data['cid']=(String)$shop->cid;
			$data['sid']=(String)$shop->sid;
			$data['nick']=(String)$shop->nick;
			$data['title']=(String)$shop->title;
			$data['desc']=(String)$shop->desc;
			$data['bulletin']=(String)$shop->bulletin;
			$data['logo_path']='http://logo.taobao.com/shop-logo'.(String)$shop->pic_path;
			$data['item_score']=(String)$shop->shop_score->item_score;
			$data['service_score']=(String)$shop->shop_score->service_score;
			$data['delivery_score']=(String)$shop->shop_score->delivery_score;
			$this->db_ship->addNewShop($data);
		}
	}
}

?>